package com.bitdf.txing.chat.constant;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author Lizhiwei
 * @date 2022/11/23 19:09:53
 * 注释：全局常量
 */
public class Constant {
    //webSocketServerHandshaker表，用channelId为键，存放握手实例。用来响应CloseWebSocketFrame的请求
    public static Map<String, WebSocketServerHandshaker> webSocketServerHandshakerMap =
            new ConcurrentHashMap<>();

    //onlineUser表，用userEmail为主键，存放在线的客户端连接上下文
    public static Map<String, ChannelHandlerContext> onlineUser =
            new ConcurrentHashMap<>();

    //用于存储每个在线用户的在线好友id
    public static Map<Integer, List<Integer>> onlineFriends =
            new ConcurrentHashMap<>();

    //id和ctx对照表
    public static Map<Integer, ChannelHandlerContext> idToCtx =
            new ConcurrentHashMap<>();

    /**
     * redis  聊天信息key 私聊
     */
    public static String CHATMESSAGE_SINGLE="txing:chat:chatMessage:single:";
    /**
     * redis  聊天信息key 群聊
     */
    public static String CHATMESSAGE_GROUP="txing:chat:chatMessage:group:";
    /**
     * redis  聊天记录key
     */
    public static String CHATHISTORY="txing:chat:chatHistory:";
    /**
     *  好友最后读取时间
     */
    public static String CHATREADTIME="txing:chat:LastReadTime:";
    /**
     * 某对用户的最后一条已持久化的聊天记录的时间
     */
    public static String LSAT_SAVE_MESSAGE_TIME="txing:chat:lastSaveMessageTime:";

    /**
     * retrun flag
     */

    public static String SUCCESS="success";

    public static String REPEAT="repeat";

    public static String ALREADY="already";

    public static String FAILURE="failure";


    /**
     * 聊天信息类型
     */
    /**
     * 私聊
     */
    public static String SINGLE_SENDING="single_sending";
    /**
     * 群发
     */
    public static String GROUP_SENDING="group_sending";
    /**
     * 组团申请
     */
    public static String GROUP_REQUEST="group_request";
    /**
     * 同意或拒绝 组团申请
     */
    public static String AGREE_OR_REJECT_GROUP_REQUEST="agree_or_reject_group_request";

    /**
     * 注册（用户上线后把该用户id加入到onlineMap中）
     */
    public static String REGISTER="register";
    /**
     *  好友请求 反馈
     */
    public static String ADD_FRIEND_REQUEST_REPLY="add_friend_request_reply";
    /**
     * 同意/拒绝 好友请求
     */
    public static String AGREE_OR_REJECT_FRIEND_REQUEST="agree_or_reject_friend_request";
    /**
     * 已读反馈
     */
    public static String READ_REPLY_SENDING="read_reply_sending";
    /**
     *  类型错误
     */
    public static String TYPE_ERROR="type_error";






}
